﻿using QRCoder;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace Partner.Utility
{

    public class QRCodeEncoder
    {
        public QRCodeEncoder()
        {

        }

        public virtual ERROR_CORRECTION QRCodeErrorCorrect { get; set; }
        public virtual int QRCodeVersion { get; set; }
        public virtual ENCODE_MODE QRCodeEncodeMode { get; set; }
        public virtual int QRCodeScale { get; set; }
        public virtual Color QRCodeBackgroundColor { get; set; }
        public virtual Color QRCodeForegroundColor { get; set; }

        public virtual bool[][] CalQrcode(byte[] qrcodeData)
        {
            return null;

        }
        public virtual int CalStructureappendParity(sbyte[] originaldata)
        {
            return 0;

        }
        public virtual Bitmap Encode(string content)
        {
            
            QRCodeGenerator generator = new QRCodeGenerator();
            QRCodeData codeData = generator.CreateQrCode(content, QRCodeGenerator.ECCLevel.M, true);
            QRCoder.QRCode qrcode = new QRCoder.QRCode(codeData);

            Bitmap qrImage = qrcode.GetGraphic(QRCodeScale, Color.Black, Color.White, true);

            return qrImage;
        }
        
        public virtual void SetStructureappend(int m, int n, int p)
        {

        }

        public enum ENCODE_MODE
        {
            ALPHA_NUMERIC = 0,
            NUMERIC = 1,
            BYTE = 2
        }
        public enum ERROR_CORRECTION
        {
            L = 0,
            M = 1,
            Q = 2,
            H = 3
        }
    }

}
